<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@taglib uri="/WEB-INF/tld/pageutil.tld" prefix="pu"%>
<%@taglib uri="/WEB-INF/tld/pageable.tld" prefix="pageable"%>
<%@taglib uri="http://java.sun.com/jstl/core" prefix="c"%>
<%@taglib uri="http://java.sun.com/jstl/core_rt" prefix="c-rt"%>
<%@taglib uri="http://java.sun.com/jstl/fmt_rt" prefix="fmt-rt"%>
<script>
$(function(){
$('#search').click(function(){
	document.workOrderForm.submit();
});
});
</script>
<c-rt:set var="tp" value="${pu:pageableTag('tpp', 10, 10)}"/>
<c-rt:if test="${empty param.keyword}">
	<c-rt:set var="results" value="${pu:queryByHql('from TaskGroup order by createDate desc', null, tp)}"/>
</c-rt:if>
<c-rt:if test="${!empty param.keyword}">
	<c-rt:set var="hql">
	from TaskGroup where id like ? or name like ? order by createDate desc
	</c-rt:set>
	<c-rt:set var="keyword">
	%${param.keyword }%
	</c-rt:set>
	<c-rt:set var="params" value="${pu:addToList('paras', keyword)}"/>
	<c-rt:set var="params" value="${pu:addToList('paras', keyword)}"/>
	<c-rt:set var="results" value="${pu:queryByHql(hql, params, tp)}"/>
</c-rt:if>
<div class="f-link"><a href="/ecadmin/cs/taskGroup/page.do?iamlazy=toUpdate" id="questionToAdd">建立</a></div>
<div class="f-link"><a href="/ecadmin/cs/taskGroup/page.do?iamlazy=userList" id="userList">使用者列表</a></div>
<h1>任务分组管理

</h1>
<form name="workOrderForm" id="workOrderForm" method="post" action="/ecadmin/cs/taskGroup/page.do">
<input type="hidden" name="iamlazy" value="list"/>
<table>
<tr>
<td>关键字:<input type="text" value="${param.keyword }" name="keyword"/></td><td><div class="f-link"><a href="javascript:;" id="search">search</a></div></td>
</tr>
</table>
</form>

<table class="tb-1" width="100%">
		<thead>
			<tr>
				<th></th>
				<th>编号</th>
				<th>名称</th>
				<th>父分组</th>
				<th>建立时间</th>
			</tr>
		</thead>
		<tbody>
			<c-rt:forEach items="${results}" var="result" varStatus="rows_index">
				<tr class="${rows_index.count % 2 == 0 ? 'bg-yl' : ''}">
					<td>
					<input type="button" value="编辑" onclick="location.href='/ecadmin/cs/taskGroup/page.do?iamlazy=toUpdate&taskGroupId=${result.id}'"/>
					<input type="button" value="編輯群組使用者" onclick="location.href='/ecadmin/cs/taskGroup/page.do?iamlazy=toUpdateGroupUser&taskGroupId=${result.id}'"/>
					</td>
					<td><a href="/ecadmin/cs/taskGroup/page.do?iamlazy=toUpdateGroupUser&taskGroupId=${result.id }">${result.id }</a></td>
					<td>${result.name }</td>
					<td>${result.parent.name }</td>
					<td><fmt-rt:formatDate value="${result.createDate }" pattern="yyyy/MM/dd HH:mm"/></td>
				</tr>
			</c-rt:forEach>
		</tbody>
	</table> 
<c-rt:set var="url">
<%=application.getContextPath() %>/cs/taskGroup/page.do?iamlazy=list
</c-rt:set>
<pageable:Pageable url="${url}" escapeparams="iamlazy,AJAX,refreshZone" formname="csForm" key="tpp"></pageable:Pageable>
